<template>
	<view class="content">
		<view class="hei20"></view>
		<view class="wid90 mar bacFFF borRad20" style="height: 227rpx;">
			<view class="wid90 mar dis disAl disJuB hei100">
				<view class="dis disAl">
					<image :src="url+userInfo.avatar" class="borRad50" style="width: 128rpx;height: 128rpx;"></image>
					<view class="fowe600 foSi40 mar-left30">{{userInfo.name}}</view>
				</view>
				<view v-if="userInfo.identity == 0" class="hei60 dis disAl disJuC fowe600 foSi25 coFFF borRad10" 
					style="width: 106rpx;background-color: #035DFF;">店长</view>
				<view v-if="userInfo.identity == 1" class="hei60 dis disAl disJuC fowe600 foSi25 coFFF borRad10"
					style="width: 106rpx;background-color: #035DFF;">店员</view>
			</view>
		</view>
		<view class="wid90 mar borRad20 bacFFF mar-top30" style="padding: 10rpx 0;">
			<view class="wid90 mar hei80 dis disAl disJuB" @click="tiaozhuan('/pages/wode/install')">
				<view class="foSi30 fowe600 mar-left20">账号设置</view>
				<uni-icons type="right" size="30rpx"></uni-icons>
			</view>
			<view class="wid90 mar hei80 dis disAl disJuB" @click="tiaozhuan('/pages/shop/install')">
				<view class="foSi30 fowe600 mar-left20">修改密码</view>
				<uni-icons type="right" size="30rpx"></uni-icons>
			</view>
		</view>
		
		<view class="poFix wid100 bacFFF" style="bottom: 0;">
			<view class="wid90 mar dis disAl" style="height: 125rpx;">
				<view class="textCen" style="width: 40%;" @click="tiaozhuan1('/pages/shop/workbench')">
					<image src="../../static/tabbar/workbench.png" style="width: 40rpx;height: 40rpx;"></image>
					<view class="mar-top10 foSi25">工作台</view>
				</view>
				<view class="textCen" style="width: 20%;" @click="scan">
					<image src="../../static/tabbar/zu.png" style="width: 135rpx;height: 135rpx;margin-top: -50rpx;"></image>
				</view>
				<view class="textCen" style="width: 40%;">
					<image src="../../static/tabbar/install-on.png" style="width: 40rpx;height: 40rpx;"></image>
					<view class="mar-top10 foSi25" style="color: #035DFF;">设置</view>
				</view>
			</view>
			<view v-if="bottomHight != 0" :style="'height: '+(bottomHight - 20)+'px;'"></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				bottomHight: 0,
				userInfo: '',
				code: ''
			}
		},
		onLoad() {
			let app = uni.getSystemInfoSync();
			this.bottomHight = app.safeAreaInsets.bottom //屏幕底部安全距离
			this.userInfo =  uni.getStorageSync('yuan_userinfo')
		},
		onShow() {},
		methods: {
			scan: function(e){
				var that = this;
				uni.scanCode({
				    onlyFromCamera: true,
				    success: function (res) {
				        //console.log('条码内容：' + res.result);
						var strs= new Array(); //定义一数组 
						strs=res.result.split("_"); //字符分割
						that.code = strs[0];
						uni.showModal({
						    title: '温馨提示',
						    content: '确认要核销吗?',
						    success: function (res) {
						        if (res.confirm) {
									that.getCheck()
						        } else if (res.cancel) {
						            uni.showToast({
						            	title:'取消核销',
						            	icon:'none',
								duration: 1000
						            })
						        }
						    }
						});
				    }
				})
			},
			getCheck() {
				var that = this;
				var yuan_userinfo = uni.getStorageSync('yuan_userinfo')
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_integralorder_check',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						'gas_station_id': yuan_userinfo.gas_station_id,
						'clerk_id': yuan_userinfo.id,
						'code': that.code
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							uni.showToast({
								title: '核销成功',
								icon: 'none',
								duration: 1000
							});
						}else{
							uni.showToast({
								title: result.msg,
								icon: 'none',
								duration: 1000
							});
						}
					}
				})
			},
			tiaozhuan(url){
				uni.navigateTo({
					url: url
				})
			},
			tiaozhuan1(url){
				uni.redirectTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		background: #F8F9FD;
		min-height: 100vh;
	}

</style>
